package com.javasm.mb_store_api_final.goodsTest;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.javasm.mb_store_api_final.giftsandgoods.goods.entity.GgGoods;
import com.javasm.mb_store_api_final.giftsandgoods.goods.service.GgGoodsService;
import com.javasm.mb_store_api_final.giftsandgoods.product.dao.GgProductDao;
import com.javasm.mb_store_api_final.giftsandgoods.product.entity.GgProduct;
import com.javasm.mb_store_api_final.giftsandgoods.product.service.GgProductService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;

/**
 * @author lh
 * @version 0.1
 * @className GoodsTest1
 * @date 2024/7/30 21:51
 * @description
 * @since jdk11
 */
@SpringBootTest
public class GoodsTest1 {
    @Resource
    GgGoodsService goodsService;
    @Resource
    private GgProductDao ggProductDao;
    @Resource
    GgProductService productService;
    @Test
    public void test1(){
        String i = "1";
        GgGoods byId = goodsService.getById(i);
        System.out.println(byId);
    }

    @Test
    public void test2(){
        GgGoods goods = goodsService.getByIdWithAnotherProperties("1");
        goods.setClassify("apple watch");

        LambdaUpdateWrapper<GgProduct> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(GgProduct::getCoding,goods.getGcode()).set(GgProduct::getClassify,goods.getClassify());
        ggProductDao.update(null,wrapper);
        GgProduct ggProduct = productService.getByCoding(goods.getGcode());
        System.out.println(ggProduct.getClassify());
    }
}
